//加载公共样式
require('../../assets/css/index.less')
require('../../assets/js/property.js')
require('../../assets/font/font_3852666_7r0dooui378/iconfont.css')

//加载自己的样式
require('./course-detail.less')

//引入ajax工具函数
const request = require('../../assets/js/requers')
//服务器地址
const API = 'http://fitness.h5.itsource.cn:3701'

window.onload = () => {
  const courseId = location.search.split('=')[1]
  console.log('courseId', courseId)

  //获取数据
  function getData() {
    request
      .get('/api/train/courseDetail', {
        params: {
          id: courseId,
      
        },
      })
      .then(res => {
        console.log('res.data :>> ', res.data)
        //解构数据
        let {errno, data} = res.data
        //判断
        if (errno === 0) {
          //把训练数据存储到本地 给play页面用
          //给视频src赋值
   $('#player').src = API + data.fragments[0].videoUrl
          localStorage.setItem('fragments', JSON.stringify(data.fragments))
        }
      })
  }

  //初始化发请求
  getData()

   // 渲染函数
   function renderData(data){
    $('#data1').textContent=data.name
    $('#calorie').textContent=data.calorie
    $('#time').textContent=data.time
    $('#people').textContent=data.peoplenum+'人练过>'
    $('#userimg').src=url+data.imgurl
    $('#detail').textContent=data.desc
    $('.data2').textContent='每周'+data.frequency+'次'
    $('.tool').textContent=data.instrument



}
// 点击播放按钮
$('.icon-bofang').addEventListener('click',()=>{
    $('.mask').style.display='none'
    $('.paly').style.display='none'
    $('.player').play()


})
 
}
